<?php
$id = 0;
$table = "product_cat";
$mod = $_GET['mod'];
$title_add = 'Add "Product Category"';
if (isset($_GET['id'])) {
    $id = $_GET['id'];
    $te = find("select * from $table where id='$id'", 'single');
    $title_add = 'Edit "Product Category"';
}
?>

<div class="page-header">
    <div class="pull-left"><?= $title_add ?></div>
    <div class="pull-right"></div>
    <div class="clear"></div>
</div>

<form class="form-horizontal" role="form" name="frmedit" method="post" enctype="multipart/form-data" action="<?= $id == 0 ? "?mod=$mod&act=process" : "?mod=$mod&act=process&id=$id" ?>">

    <div class="form-group">
        <label class="col-sm-3 control-label">Category</label>
        <div class="col-sm-9">
            <select name="parentid" class="form-control">
                <option value="0">Root</option>
                <?php echo listProductCat($te["parentid"], 0, 0, 2, $id); ?>								
            </select>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-3 control-label">Title :</label>
        <div class="col-sm-9">
            <input name="title" type="text" class="form-control" value="<?= $te['title'] ?>" >
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-3 control-label">Title (Vietnamese) :</label>
        <div class="col-sm-9">
            <input name="title_vn" type="text" class="form-control" value="<?= $te['title_vn'] ?>" >
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-3 control-label">Image (670px*220px) : </label>
        <div class="col-sm-9">
            <input type="file" name="image"  />
            <?php
            if ($te['image'] != "" && file_exists("../product-img/" . $te['image'])) {
                echo '<br/><img class="img-thumbnail" src="../product-img/' . $te['image'] . '"  />';
            }
            ?>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-3 control-label">Keywords :</label>
        <div class="col-sm-9">
            <textarea name="meta_key" class="form-control" ><?= $te['meta_key'] ?></textarea>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-3 control-label">Description :</label>
        <div class="col-sm-9">
            <textarea name="meta_des" class="form-control" ><?= $te['meta_des'] ?></textarea>
        </div>
    </div>

    <div class="form-group">
        <div class="col-sm-offset-3 col-sm-9">
            <button type="submit" class="btn btn-primary">Save</button>
            <button type="reset" class="btn btn-default">Reset</button>
        </div>
    </div>
    <input type="hidden" name="form_" value="edit">
</form>